package com.dogstudio.mygame.config;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * 项目配置信息
 */

public class Config {
    public static final int GAME_SUCCESS_EXTRA = 1000;
    public static final int SCREEN_WIDTH = 720;
    public static final int SCREEN_HEIGHT = 1280;

    public static String TAG = "Game_app";
    public static boolean IS_DEBUG = true;

    public static final String SCORE = "2048_score";
    public static final String BEST_SCORE = "best_score";
    private static SharedPreferences preferences;

    public static int getBestScore(Context context) {
        if (preferences == null) {
            preferences = context.getSharedPreferences(SCORE, Context.MODE_PRIVATE);
        }
        return preferences.getInt(BEST_SCORE, 0);
    }

    public static void saveBestScore(Context context, int curScore) {
        int bestScore = getBestScore(context);
        if (bestScore < curScore) {
            if (preferences == null) {
                preferences = context.getSharedPreferences(SCORE, Context.MODE_PRIVATE);
            }
            SharedPreferences.Editor editor = preferences.edit();
            editor.putInt(BEST_SCORE, curScore);
            editor.commit();
        }
    }


}
